package operation;

import book.BookList;

import java.util.Scanner;

public class BorrowBook implements Ioperation{
    public void work(BookList bookList){
        while(true) {
            boolean isBorrow=false;
            Scanner ip = new Scanner(System.in);
            System.out.println("输入要查找的书名：");
            String name = ip.nextLine();
            for (int i = 0; i < bookList.getNumber(); i++) {
                if (name.equals(bookList.getBook(i).getName())) {
                    System.out.println("成功借出");
                    bookList.getBook(i).setBorrow(true);
                    isBorrow=true;
                    break;
                }
                if (i== bookList.getNumber()-1&&!isBorrow)
                    System.out.println("没有找到这本书");
            }
            System.out.println("是否继续借书");
            System.out.println("1.借书  2.退出");
            int out = ip.nextInt();
            if (out == 2)
                break;
        }
    }
}
